package com.yi.serviceverificationcode.controller;

import com.yi.internalcommon.dto.ResponseResult;
import com.yi.internalcommon.responese.NumberCodeResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class NumberCodeController {
    /**
     * 生成验证码
     * @param size
     * @return
     */
    @GetMapping("/numberCode/{size}")
    public ResponseResult numberCode(@PathVariable("size") int size){
        //生成验证码
        double mathRandom = ((Math.random() * 9) + 1)* Math.pow(10,size-1);
        int resultInt= (int) mathRandom;
        //定义返回值
        NumberCodeResponse response=new NumberCodeResponse();
        response.setNumberCode(resultInt);
        return ResponseResult.success(response);
    }


}
